<template>
<!-- 引入资产 -->
	<Modal
        v-model="rzShow"
        :title="title"
        @on-ok="import_ok"
		:width="1000"
        >
        <div>
			<Form :model="filter" :label-width="150" style="width: 100%" :rules="ruleValidate">
				<Row>
					<Col span="12">
						<FormItem label="导入时间范围：" prop="month">
							<Input v-model="filter.date_month" placeholder="请输入关键词" style="width: 240px"></Input>
						</FormItem>
					</Col>
				</Row>
				<Row>
					<Col span="12">
						<FormItem label=" 类型：">
							<Select v-model="filter.region" placeholder="请选择类型" style="width: 240px">
								<Option v-for="item in companyList" :value="item.id" :key="item.id">{{ item.name }}</Option>
							</Select>
						</FormItem>
					</Col>
					<Col span="12">
						<FormItem label="承担部门：">
							<bumen_filter v-model="filter.bumen" field="name" style="width: 240px"></bumen_filter>
						</FormItem>
					</Col>
				</Row>
				<Row>
					<Col span="12">
						<FormItem label="公司主体：">
							<company_list v-model="filter.company" field="name" style="width: 240px"></company_list>
						</FormItem>
					</Col>
					<Col span="12">
						<FormItem label="费用科目：">
							<subject_filter v-model="filter.subject" field="name" style="width: 240px" v-if="title=='引入入账'"></subject_filter>
							<Input v-model="filter.subject" style="width: 240px" disabled v-else></Input>
						</FormItem>
					</Col>
				</Row>
				<Row>
					<Col span="12">
						<FormItem label="地区：">
							<region_list v-model="filter.region" field="name" style="width: 240px"></region_list>
						</FormItem>
					</Col>
				</Row>
				
			</Form>
		</div>
		<div slot="footer" style="text-align: center;">
			<Button type="success" size="large"  @click="einfo_ok">导入</Button>
		</div>
    </Modal>
</template>

<script>
import region_list from '@/themes/components/region_list';
import company_list from '@/themes/components/company_list';
import bumen_filter from '@/themes/components/bumen_filter';
import subject_filter from '@/themes/components/subject_filter';
export default {
  name: 'zichan_bar',
  data(){
	return {
		// title:'引入入账',
		rzShow:false,
		filter:{
			date_month:new Date().Format('yyyy-MM'),
			keyword:'',
			region:'',
			company:'',
			bumen:'',
			subject:'',
			bz:'人民币',
		},
		ruleValidate:{
			month:[
				{ required: true, message: '导入时间范围不能为空', trigger: 'blur' }
			]
		},
		companyList:[]
	};
  },
  components:{
		region_list,
		company_list,
		bumen_filter,
		subject_filter,
	},
  props:['value','title'],
  created(){
	this.show = this.value;
	
  },
  watch:{
	value(val){
		this.rzShow = val;
	},
	rzShow(val){
		this.$emit('input',val);
	},
	title(val){
		this.title = val;
	},
  },
  methods: {
	einfo_ok(){
	
		var self = this;
		var data =  [this.filter];
		var postdata = {
			data:JSON.stringify(data),
			date_month:this.filter.date_month,
			company_id:this.filter.id
		};
		
		Whttp.load('Chuna/Cash/update',postdata,function(result){
			self.rzShow = false;

			self.load_data();
			self.$Message.info('提交成功');
		});
		
	},
	import_ok(){
			var self = this;
			var postdata = {
				mark:this.imports.mark,
				company_id:this.imports.company_id
			};
			Whttp.load('Chuna/Bank/import_data',postdata,function(result){
				alert('导入成功');
			},function(result){
				alert(result.message);
			});
		},
  }
}
</script>
<style scoped>
.price{
	color: red;
    margin: 0 5px;
}
.defwid{
	width:220px;
}
</style>